home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dirut / eren.zip / EREN.ASM next >
Assembly Source File  |  1985-09-06  |  3KB  |  69 lines

  1.         PAGE    72,120
  2.  
  3. TITLE   SREN Change name of file, sub-dir, or Vol. ID
  4.  
  5. COMMENT *       SREN   [d:]name1  name2
  6.         Renames files or subdirectories from name1 to name2.
  7.         Name1 & Name2 may have extensions and wild characters.
  8.         Action of the program is as described in the DOS manual
  9.         for INT 21, Function 17.
  10.  
  11. *
  12. COM     SEGMENT
  13.         ASSUME  CS:COM, DS:COM, ES:COM, SS:COM
  14.  
  15.         ORG     05CH                    ; FCB formed from Name1
  16. fcb1    LABEL   BYTE
  17. drive1  db      ?
  18. name1   db      11 DUP (?)
  19.  
  20.         ORG     06CH                    ; FCB formed from name2
  21. fcb2    LABEL   BYTE
  22. drive2  db      ?
  23. name2   db      11 DUP (?)
  24.  
  25.         ORG     100H
  26.  
  27. SREN    PROC
  28.         mov     dx, offset invdr$       ; Point to error message
  29.         test    al,al                   ; Test for valid drive ID
  30.         jnz     error                   ; Xfr - invalid drive ID
  31.         mov     dx,offset invpar$       ; Get pointer to next error message
  32.         cmp     name1,' '               ; Check for presence of Name1
  33.         je      error                   ; Xfr - no Name1
  34.         cmp     name2,' '               ; Check for presence of Name2
  35.         je      error                   ; Xfr - no Name2
  36.         mov     si, offset fcb1         ; Get ptr to Name1 FCB
  37.         mov     di, offset oldn         ; Get ptr to 'old' name field
  38.         mov     cx,12                   ; Set move count for 12 bytes
  39.         rep     movsb                   ; Move name1 to Extended FCB
  40.         mov     si, offset name2        ; Get ptr to Name2 - not drive
  41.         mov     di, offset oldn+11H     ; Get ptr to 'new' name field
  42.         mov     cx,11                   ; Set move count for 11 bytes
  43.         rep     movsb                   ; Move 'new' name to Extended FCB
  44.         mov     dx, offset xfcb         ; Get ptr to Extended FCB for DOS
  45.         mov     ah,17H                  ; ... MS-DOS 'Rename' function
  46.         int     21H                     ; ... MS-DOS entry interrupt
  47.         test    al,al                   ; Test for errors
  48.         jz      exit                    ; Xfr - no errors - exit program
  49.         mov     dx, offset invnam$      ; Get ptr to error message
  50. error:  mov     ah,9                    ; ... MS-DOS 'Print Message' function
  51.         int     21H                     ; ... MS-DOS entry interrupt
  52. exit:   int     20H                     ; EXIT - MS-DOS 'Terminate' interrupt
  53. SREN    ENDP
  54.  
  55. invdr$  db      0DH,0AH,'Invalid drive ID',0DH,0AH,'$'
  56.  
  57. invpar$ db      0DH,0AH,'2 Params needed- [d:]oldname newname',0DH,0AH,'$'
  58.  
  59. invnam$ db      0DH,0AH,'Name not found or already exists',0DH,0AH,'$'
  60.  
  61. xfcb    db      0FFH                    ; Extended FCB ID byte
  62.         db      5 DUP (0)
  63. attr    db      18H                     ; Attr byte for sub-dirs & vol labels
  64. oldn    db      37 DUP (0)              ; Old & New name fields
  65.  
  66. COM     ENDS
  67.  
  68.         END     SREN
  69.